|
Book details / order |
EFFECTIVE PYTHON: 59 SPECIFIC WAYS TO WRITE BETTER PYTHON |
Effective python will help students harness the full power of python to write exceptionally robust, efficient, maintainable, and well-performing code. utilizing the concise, scenario-driven style pioneered in scott meyers's best-selling effective c++, brett slatkin brings together 53 python best practices, tips, shortcuts, and realistic code examples from expert programmers. each section contains specific, actionable guidelines organized into items, each with carefully worded advice supported by detailed technical arguments and illuminating examples.
table of content
chapter 1: pythonic thinking
item 1: know which version of python you're using
item 2: follow the pep 8 style guide
item 3: know the differences between bytes, str, and unicode
item 4: write helper functions instead of complex expressions
item 5: know how to slice sequences
item 6: avoid using start, end, and stride in a single slice
item 7: use list comprehensions instead of map and filter
item 8: avoid more than two expressions in list comprehensions
item 9: consider generator expressions for large comprehensions
item 10: prefer enumerate over range
item 11: use zip to process iterators in parallel
item 12: avoid else blocks after for and while loops
item 13: take advantage of each block in try/except/else/finally
chapter 2: functions
item 14: prefer exceptions to returning none
item 15: know how closures interact with variable scope
item 16: consider generators instead of returning lists
item 17: be defensive when iterating over arguments
item 18: reduce visual noise with variable positional arguments
item 19: provide optional behavior with keyword arguments
item 20: use none and docstrings to specify dynamic default arguments
item 21: enforce clarity with keyword-only arguments
chapter 3: classes and inheritance
item 22: prefer helper classes over bookkeeping with dictionaries and tuples
item 23: accept functions for simple interfaces instead of classes
item 24: use @classmethod polymorphism to construct objects generically
item 25: initialize parent classes with super
item 26: use multiple inheritance only for mix-in utility classes
item 27: prefer public attributes over private ones
item 28: inherit from collections.abc for custom container types
chapter 4: metaclasses and attributes
item 29: use plain attributes instead of get and set methods
item 30: consider @property instead of refactoring attributes
item 31: use descriptors for reusable @property methods
item 32: use __getattr__, __getattribute__, and __setattr__ for lazy attributes
item 33: validate subclasses with metaclasses
item 34: register class existence with metaclasses
item 35: annotate class attributes with metaclasses
chapter 5: concurrency and parallelism
item 36: use subprocess to manage child processes
item 37: use threads for blocking i/o, avoid for parallelism
item 38: use lock to prevent data races in threads
item 39: use queue to coordinate work between threads
item 40: consider coroutines to run many functions concurrently
item 41: consider concurrent.futures for true parallelism
chapter 6: built-in modules
item 42: define function decorators with functools.wraps
item 43: consider contextlib and with statements for reusable try/finally behavior
item 44: make pickle reliable with copyreg
item 45: use datetime instead of time for local clocks
item 46: use built-in algorithms and data structures
item 47: use decimal when precision is paramount
item 48: know where to find community-built modules
chapter 7: collaboration
item 49: write docstrings for every function, class, and module
item 50: use packages to organize modules and provide stable apis
item 51: define a root exception to insulate callers from apis
item 52: know how to break circular dependencies
item 53: use virtual environments for isolated and
reproducible dependencies
chapter 8: production
item 54: consider module-scoped code to configure deployment environments
item 55: use repr strings for debugging output
item 56: test everything with unittest
item 57: consider interactive debugging with pdb
item 58: profile before optimizing
item 59: use tracemalloc to understand memory usage and leaks
salient features
• covers python algorithms, objects, concurrency, collaboration, built-in modules, and much more
• addresses both python 3 and python 2
• guides students to a far deeper understanding of the python language, so they know why its unique idioms and rules of thumb make sense
• follows the enormously popular "effective" format proven in scott meyers' classic effective c++.
Author : Brett slatkin
Publication : Pearson
Isbn : 9789332552364
Store book number : 107
NRS 600.00
|
|
|
|
|
|
|
|
|
|